# coding=utf-8
import allure
from common.assert_operator import *
from common.db import *
from common.read_yaml import *
from common.utils import Utils

string_assert = string_assert() # 字符串校验类
pact = Pact() # 契约校验类
execute_sql = sql() # sql集合
utils = Utils()
data = ReadYaml_By_Root_Dict("case/99_outside_api_test/02_bpm_outside_test/99_02_2_GetProcessNodeDataControl_GetByIds.yml").get_yaml_data()  # 读取数据

@allure.feature('测试流程中心外部接口：获取任务对应权限设置，根据用户id获取用户信息')  # 测试报告显示测试功能
class Test_99_02_2_GetProcessNodeDataControl_GetByIds():
    """
    测试接口：
    /api/flowinstance/approval/get-process-node-data-control
    /api/resource/user/get-by-ids
    """
    # 获取yml文件中[获取任务对应权限设置]的数据参数
    Params = data['获取任务对应权限设置']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetProcessNodeDataControl(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['用例描述']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Bpm_Outside_Api(param['用户'])
        resp = main.get_process_node_data_control(param['请求体'])
        dict_assert(expect['响应校验'],resp.json())    # 结果断言

    # 获取yml文件中[获取任务对应权限设置_异常场景]的数据参数
    Params = data['获取任务对应权限设置_异常场景']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetProcessNodeDataControl_Abnormal(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['用例描述']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Bpm_Outside_Api(param['用户'])
        resp = main.get_process_node_data_control(param['请求体'])
        dict_assert(expect['响应校验'],resp.json())    # 结果断言

    # 获取yml文件中[获取用户信息]的数据参数
    Params = data['获取用户信息']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetByIds(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['用例描述']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Bpm_Outside_Api(param['用户'])
        resp = main.get_by_ids(param['请求体'])
        dict_assert(expect['响应校验'],resp.json())    # 结果断言

    # 获取yml文件中[获取用户信息_异常场景]的数据参数
    Params = data['获取用户信息_异常场景']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetByIds_Abnormal(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['用例描述']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Bpm_Outside_Api(param['用户'])
        resp = main.get_by_ids(param['请求体'])
        dict_assert(expect['响应校验'],resp.json())    # 结果断言
